package com.whminwei.edu.api.sso.client;

import com.whminwei.common.exception.ServiceException;
import com.whminwei.common.feign.decoder.FullHttpRspnConfig;
import com.whminwei.common.http.rspn.BaseHttpResponse;
import com.whminwei.common.http.rspn.FullHttpResponse;
import com.whminwei.edu.api.sso.pojo.bo.AuthBo;
import com.whminwei.edu.api.sso.pojo.msg.req.AuthWithTokenReq;
import com.whminwei.edu.api.sso.pojo.msg.req.AuthWithoutTokenReq;
import com.whminwei.edu.api.sso.pojo.msg.req.LogoutReq;
import com.whminwei.edu.api.sso.pojo.msg.req.VerifyPasswordReq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author wangy
 * @since 2023-12-17
 */
@FeignClient(name = "xzzg-sso-service", contextId = "for-auth", configuration = FullHttpRspnConfig.class)
public interface AuthClient {

    /**
     * 向SSO请求鉴权，带token
     *
     * @return 权限信息 com.whminwei.edu.api.sso.bo.AuthBo
     * @throws ServiceException SSO接口请求异常，没有得到来自SSO的响应结果、响应结果无法解析或响应失败
     */
    @PostMapping("/authWithToken")
    FullHttpResponse<AuthBo> authWithToken(@RequestBody @Validated AuthWithTokenReq req) throws ServiceException;

    /**
     * 向SSO请求鉴权，不带token
     *
     * @return 权限信息 com.whminwei.edu.api.sso.bo.AuthBo
     * @throws ServiceException SSO接口请求异常，没有得到来自SSO的响应结果、响应结果无法解析或响应失败
     */
    @PostMapping("/authWithoutToken")
    FullHttpResponse<AuthBo> authWithoutToken(@RequestBody @Validated AuthWithoutTokenReq req) throws ServiceException;

    /**
     * 向SSO请求校验密码
     *
     * @return 校验结果，仅当账号、密码正确时返回true
     * @throws ServiceException soApiException SSO接口请求异常，没有得到来自SSO的响应结果、响应结果无法解析或响应失败
     */
    @PostMapping("/verifyPassword")
    BaseHttpResponse verifyPassword(@RequestBody @Validated VerifyPasswordReq req) throws ServiceException;




    @PostMapping("/ssoLogout")
    BaseHttpResponse logout(@RequestBody @Validated LogoutReq req) throws ServiceException;


}
